package hotel.quartz.oversea.job.switchs;

import hotel.base.oversea.constant.CommonUrlConstants;
import hotel.base.oversea.constant.SwitchConstants;
import hotel.base.oversea.constant.quartz.UrlSwitchsEnums;
import hotel.base.oversea.utils.RestTemplateUtils;
import hotel.base.oversea.utils.Result;
import hotel.quartz.oversea.job.base.BaseJob;
import hotel.quartz.oversea.service.JobAndTriggerService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.client.RestTemplate;

/**
 * @Auther: 你的名字
 * @Date: 2021/01/13/16:47
 * @Description: 新增酒店
 */
@Slf4j
public class SwitchControlAddHotelUpJob implements BaseJob {
    //任务分组
    private String jobGroupName= SwitchConstants.JOB_GROUP_NAME_SWITCHS;
    //类名
    private String jobClassName=this.getClass().getName();

    @Autowired
    private JobAndTriggerService jobAndTriggerService;
    @Autowired
    private RestTemplate restTemplate;



    /***
     * @Author: lmf
     * @Date: 2020/12/28
     *  暂时通过redis来控制
     */
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        log.info("==================进入控制酒店上下线和增量定时器=============================");
        String host = CommonUrlConstants.SWITCHS_ONLINE_HOST;

        String addHotelListHotelGetUrl = host + UrlSwitchsEnums.SwitchCheckHotelRoomIsCreateJob.SWITCH_ADD_HOTEL_LIST.getValue();
        Result result= RestTemplateUtils.get(addHotelListHotelGetUrl,null,restTemplate);
        log.info("==========添加新的酒店返回结果为{}===========",result.toString());


    }
}
